import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'
import { autoRegisterRoute } from './autoRegisterRoute'
import { RouteItem } from '@/types/route'

export const routes: RouteItem[] = [
  {
    path: '/',
    component: Layout,
    name: 'layout',
    meta: {
      sort: 0,
      parentKey: null,
      isMenu: false
    },
    redirect: '/home',
    children: autoRegisterRoute()
  }
]
console.log(routes)

// 创建路由实例
export const router = createRouter({
  history: createWebHashHistory(),
  routes: routes as RouteRecordRaw[]
})

export function registerRouter(app: any) {
  app.use(router)
}
